Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ecdsa cert support for client through SSH agent #1440

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xRemaLx
Copy link

@xRemaLx xRemaLx commented Jan 25, 2025

Add ecdsa-sha2-nistp(256|384|521)[email protected] for client through SSH_AGENT

It is work in case from #910 and #858

I test on my server like this:

const { Client } = require('ssh2');

const conn = new Client();
conn.on('ready', () => {
    console.log('Client :: ready');
    conn.exec('uptime', (err, stream) => {
        if (err) throw err;
        stream.on('close', (code, signal) => {
          console.log('Stream :: close :: code: ' + code + ', signal: ' + signal);
          conn.end();
        }).on('data', (data) => {
          console.log('STDOUT: ' + data);
        }).stderr.on('data', (data) => {
          console.log('STDERR: ' + data);
        });
    });
}).connect({
    host: 'test.server',
    port: 22,
    username: 'xremalx',
    agent: process.env.SSH_AUTH_SOCK,
});

@kobrineli
Copy link

@mscdex
Hi! Could you review this, please?

@xRemaLx
Copy link
Author

xRemaLx commented Feb 7, 2025

@mscdex
Hi! Are there any updates on this? Could you review this, please?

@@ -1390,6 +1390,28 @@ function parseDER(data, baseType, comment, fullType) {
return new OpenSSH_Public(fullType, comment, pubPEM, pubSSH, algo);
}

function tryParseAsCert(data, baseType, comment) {
if (!isSupportedCertType(baseType))
return new Error(`Unsupported OpenSSH cert type: ${baseType}`);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personal note (dunno if it really makes sense): This is the only caller of isSupportedCertType and the code below generates the very same error in its default: case. So, you could remove isSupportedCertType and the two lines above without any change in behaviour.

Still, it might make sense to keep things like this just for consistency with the rest of the library (there is also isSupportedKeyType()). I'll leave that to @mscdex to decide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants